package 题目集.单调栈or队列.单调栈;

import java.util.Scanner;

public class 奶牛排队 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int[] left = new int[n];
        int[] stack = new int[n + 1];
        int top = -1;
        for (int i = 0; i < n; i++) {
            while (top != -1 && arr[stack[top]] < arr[i]) {
                top--;
            }
            left[i] = top == -1 ? -1 : stack[top];
            stack[++top] = i;
        }
        int res = 0;
        for (int i = 1; i < left.length; i++) {
            res = Math.max(res, i - left[i]);
        }
        System.out.println(res);
    }
}
